package com.ruoyi.payment.controller;


import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ruoyi.payment.dto.PaymentDto;
import com.ruoyi.payment.mapper.TbPaymentMapper;
import com.ruoyi.payment.service.TbPaymentService;
import com.ruoyi.pojo.TbPayment;

import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/payment") // 注意这里路径需要和前端请求的路径一致
public class TbPaymentController {
    @Autowired
    private TbPaymentService tbPaymentService;
    @Autowired
    private TbPaymentMapper tbPaymentMapper;

    @Autowired
    private RabbitTemplate rabbitTemplate;

    @PostMapping("/findAll")
    public Page<PaymentDto> findAll(Integer pageNum, Integer pageSize, @RequestBody PaymentDto paymentDto) {
        Page<TbPayment> page = new Page<>(pageNum, pageSize);
        return tbPaymentService.findAll(page, paymentDto);
    }

    @GetMapping("/findAll")
    public List<TbPayment> findAll() {
        return tbPaymentMapper.selectList(null);
    }


    //催缴功能方法
    @PostMapping("/send")
    public String send(@RequestBody List<Integer> ids) {
        // 发送消息到RabbitMQ
        rabbitTemplate.convertAndSend("reminderQueue", ids);
        return "0"; // 返回0表示成功
    }


}







